package com.zzh.custom.recycler;

import java.util.List;

public abstract class BaseChaosItem<B extends ChaosBean, V extends ChaosViewHolder> implements ChaosItem<B, V> {

    private ChaosAdapter mAdapter;

    public void setAdapter(ChaosAdapter mAdapter) {
        this.mAdapter = mAdapter;
    }

    protected ChaosAdapter<ChaosBean, BaseChaosItem<ChaosBean, ChaosViewHolder>, ChaosViewHolder> getAdapter() {
        return mAdapter;
    }

    protected int getSize() {
        return mAdapter.getItemCount();
    }

    protected List<ChaosBean> getList() {
        return mAdapter.getList();
    }

    protected B getBean(int index) {
        if (index <= -1) return null;
        List list = mAdapter.getList();
        if (list == null) return null;
        if (index >= list.size()) return null;
        return (B) list.get(index);
    }
}
